﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CoreRay
{
    public class StatisticsItemMemory : StatisticsItem
    {
        private long currentAllocatedMemory;
        private long totalMemory;

        public StatisticsItemMemory(string name) : base(name)
        {
            
        }

        public void RecordMemoryUsageChange()
        {
            if (currentAllocatedMemory != 0)
            {
                totalMemory += (GC.GetTotalMemory(true) - this.currentAllocatedMemory);
            }

            this.currentAllocatedMemory = GC.GetTotalMemory(true);
        }

        public override float ComputeValue()
        {
            return totalMemory;
        }
    }
}
